﻿using AMAP.Domain;
using AMAP.ServiceClasses.Common;
using AMAP.ServiceInterfaces;
using AMAP.ServiceInterfaces.Common;
using System.Linq;

namespace AMAP.ServiceClasses
{
    public class SupplierService : BaseRepositoryService<Supplier>, ISupplierService
    {
        public SupplierService(IDatabaseFactory databaseFactory)
            : base(databaseFactory)
        {
        }

        public override Supplier Create()
        {
            Supplier s = new Supplier();
            s.User = new User();
            s.User.Coordinates = new Coordinates();

            return s;
        }

        public Supplier GetByEmail(string Email)
        {
            return this.dataContext.SupplierSet.FirstOrDefault(s => s.User.Email == Email);
        }
    }
}
